package com.feizhi.inventory.fragment.main;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;

import com.feizhi.inventory.MainActivity;
import com.feizhi.inventory.R;
import com.feizhi.inventory.databinding.FragmentMainBinding;

/**
 * 主fragment
 * */
public class MainFragment extends Fragment implements View.OnClickListener {

    private FragmentMainBinding mBinding;
    private MainActivity mainActivity;

    private ImageView titleAdd;
    private TextView titleTextBack;
    private ImageView titleBack;


    public MainFragment() {
        // Required empty public constructor
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainActivity = (MainActivity) getActivity();






    }

    @SuppressLint("MissingInflatedId")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mBinding = FragmentMainBinding.inflate(inflater);
        return mBinding.getRoot();

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    private void initView() {
        titleAdd = mainActivity.findViewById(R.id.title_add);
        titleTextBack = mainActivity.findViewById(R.id.title_text_back);
        titleBack = mainActivity.findViewById(R.id.title_back);
        TextView titleText = mainActivity.findViewById(R.id.title_text);
        titleText.setText("盘点软件");
        mBinding.btnImport.setOnClickListener(this);
        mBinding.btnExport.setOnClickListener(this);


        titleAdd.setVisibility(View.GONE);
        titleTextBack.setVisibility(View.GONE);
        titleBack.setVisibility(View.GONE);

    }

    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.btn_import:
                Navigation.findNavController(mainActivity, R.id.fragment_my).navigate(R.id.inventoryPanFragment);
                break;
            case R.id.btn_export:
                Navigation.findNavController(mainActivity, R.id.fragment_my).navigate(R.id.inventorySheetFragment);
                break;
            default:break;
        }

    }
}